<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta content="yes" name="apple-mobile-web-app-capable" />
  <meta name="apple-mobile-web-app-status-bar-style" content="blank">
  <meta content="telephone=no" name="format-detection" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>天瑞商城-注册</title>
  <link rel="stylesheet" href="./css/mreset.css">
  <link rel="stylesheet" href="./css/swiper-3.4.2.min.css">
  <link rel="stylesheet" href="./css/main.css">
  <script src="js/jquery-1.11.3.min.js"></script>
  <script src="js/flexible.js"></script>
  <script src="js/swiper-3.4.2.min.js"></script>
</head>
<body ontouchstart>
  <div class="wap">
    <div class="login-head">
      <h1>注册</h1>
      <p>请准确填入以下信息</p>
    </div>
    <div class="login-box">
      <form action="">
        <div class="login-item">
          <label for="phone">手机号</label>
          <input id="phone" name="phone" type="number" placeholder="请输入您的手机号">
        </div>
        <div class="login-item generate-item">
          <input name="" class="generate" type="number" required placeholder="请输入验证码">

          <input name="" type="button" class="generate_code"  value="获取验证码">
          <div class="borderAfter"></div>
        </div>
        <div class="login-item">
          <label for="">邀请码</label>
          <input id="" name="" type="password" placeholder="请输入邀请码">
        </div>
        <div class="login-item">
          <label for="registerPwd">创建密码</label>
          <input id="registerPwd" name="registerPwd" type="password" placeholder="请设置密码">
        </div>
        <div class="login-item maginBotz">
          <label for="">确认密码</label>
          <input id="" name="" type="password" placeholder="请再次输入密码">
        </div>

        <button type="button" class="maginTo">登录</button>

      </form>
    </div>
  </div>
  <script>
    $(function(){
      $(".generate_code").click(function(){
        var disabled = $(".generate_code").attr("disabled");
        if(disabled){
          return false;
        }
        if($("#phone").val() == "" || isNaN($("#phone").val()) || $("#phone").val().length != 11 ){
          alert("请填写正确的手机号！");
          return false;
        }
        settime();
       /* $.ajax({
          async:false,
          type: "GET",
          url: "{:U('User/sms')}",
          data: {mobile:$("#mobile").val()},
          dataType: "json",
          async:false,
          success:function(data){
            console.log(data);
            settime();
          },
          error:function(err){
            console.log(err);
          }
        });*/
      });
      var countdown=60;
      var _generate_code = $(".generate_code");
      function settime() {
        if (countdown == 0) {
          _generate_code.attr("disabled",false);
          _generate_code.val("获取验证码");
          countdown = 60;
          return false;
        } else {
          $(".generate_code").attr("disabled", true);
          _generate_code.val("重新发送(" + countdown + ")");
          countdown--;
        }
        setTimeout(function() {
          settime();
        },1000);
      }
    })

  </script>
</body>
</html>